//
//  UIImage+Extension.swift
//  SinaWeibo_18
//
//  Created by apple on 15/10/27.
//  Copyright © 2015年 cz. All rights reserved.
//

import Foundation
extension UIImage{
    func scale(width width:CGFloat) -> UIImage{
        
        let scaleHeight = width/(size.width) * size.height
        let scaleSize = CGSizeMake(width, scaleHeight)
        
        UIGraphicsBeginImageContext(scaleSize)
        drawInRect(CGRect(origin: CGPointZero, size: scaleSize))
        
        let image = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return image
    }
}